<template>
  <div v-loading="!isShow">
    <div class="zs-card-sm zs-space-bottom zs-layout-flex-row">
      <el-select v-model="projectZylyCode" class="zs-select-md zs-space-right-sm" placeholder="项目名称"
        @change="changeProject">
        <el-option v-for="item in projectList" :key="item.projectZylyCode" :label="item.projectName"
          :value="item.projectZylyCode" />
      </el-select>
    </div>
    <el-scrollbar class="db-content-height" v-if="isShow">
      <div class="db-content-cards">
        <BaseInfo :biProjectCode="projectZylyCode" :projectCode="''" :permi="tabPermi" :templateCode="templateCode">
        </BaseInfo>
        <template v-if="templateCode == 1">
          <!--销售额-->
          <SalesVolume :permi="'p_btn_901_lianyinglianying_xiangqing_xiaoshoue'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></SalesVolume>
          <!--品牌情况-->
          <BrandSituation :permi="'p_btn_901_lianyinglianying_xiangqing_pinpai'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></BrandSituation>
          <!--预算对标-->
          <BudgetcAhievement :permi="'p_btn_901_lianyinglianying_xiangqing_ysdb'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></BudgetcAhievement>
        </template>
        <template v-if="templateCode == 2">
          <!--销售额-->
          <SalesVolume :permi="'p_btn_901_lianyinglianying_xiangqing_xiaoshoue'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></SalesVolume>
          <!--客流量-->
          <PassengerFlow :permi="'p_btn_901_lianyinglianying_xiangqing_keliuliang'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></PassengerFlow>
          <!--交易笔数-->
          <DealNum :permi="'p_btn_901_lianyinglianying_xiangqing_jybs'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></DealNum>
          <!-- 区位情况 -->
          <RegionSituation :permi="'p_btn_901_lianyinglianying_xiangqing_quwei'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></RegionSituation>
          <!--预算对标-->
          <BudgetcAhievement :permi="'p_btn_901_lianyinglianying_xiangqing_ysdb'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></BudgetcAhievement>
        </template>
        <template v-if="templateCode == 3">
          <!--销售额-->
          <SalesVolume :permi="'p_btn_901_lianyinglianying_xiangqing_xiaoshoue'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></SalesVolume>
          <!--客流量-->
          <PassengerFlow :permi="'p_btn_901_lianyinglianying_xiangqing_keliuliang'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></PassengerFlow>
          <!--交易笔数-->
          <DealNum :permi="'p_btn_901_lianyinglianying_xiangqing_jybs'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></DealNum>
          <!--品牌情况-->
          <BrandSituation :permi="'p_btn_901_lianyinglianying_xiangqing_pinpai'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></BrandSituation>
          <!--预算对标-->
          <BudgetcAhievement :permi="'p_btn_901_lianyinglianying_xiangqing_ysdb'" :hideList="hideList"
            :projectZylyCode="projectZylyCode" :updateDate="updateDate"></BudgetcAhievement>
        </template>
      </div>
    </el-scrollbar>

  </div>
</template>
<script setup>

import BaseInfo from '@/views/Manage/Business/components/baseInfo'
import SalesVolume from '@/views/JointVenture/components/salesVolume'
import BrandSituation from '@/views/JointVenture/components/brandSituation'
import BudgetcAhievement from '@/views/JointVenture/components/budgetcAhievement'
import PassengerFlow from '@/views/JointVenture/components/passengerFlow'
import DealNum from '@/views/JointVenture/components/dealNum'
import RegionSituation from '@/views/JointVenture/components/regionSituation'

import dbPublicApi from '@/api/dbPublic'

import { ref } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute().query
let projectZylyCode = ref(route.projectZylyCode)
let templateCode = ref(route.templateCode)
const updateDate = route.updateDate
const tabPermi = route.tabPermi

let isShow = ref(false)
let hideList = ref([])
let projectList = ref([])
const getHide = async () => {
  await dbPublicApi.queryMenuHidePcApi(projectZylyCode.value).then((res) => {
    if (res.data.code == 200) {
      hideList.value = res.data.data
    }
  })
}
const getList = () => {
  dbPublicApi.queryProjectPcApi({ dataTime: updateDate, resourceKey: tabPermi }).then((res) => {
    if (res.data.code == 200) {
      projectList.value = res.data.data
    }
  })
}
const changeProject = async (data) => {
  isShow.value = false
  await getHide()
  const index = projectList.value.findIndex(item => { return item.projectZylyCode == data })
  templateCode.value = projectList.value[index].templateCode
  isShow.value = true
}

const init = async () => {
  isShow.value = false
  await getHide()
  getList()
  isShow.value = true
}
init()

</script>

<style scoped lang="scss"></style>
